<template>
  <header >
    <div class="layui-row subject-color nav-row">
      <div class="main-content nav-menu" >
        <div class="layui-row">
          <div class="layui-col-md4 logo-box">

          </div>
          <div class="layui-col-md4 menu-box" >
            <div class="menu-ul" style="width:100%;text-align: center">
               <div>
                <router-link to="/home/context">
                  <li  style="cursor: pointer">我的首页</li>
                </router-link>

              </div>
              <div >
                <router-link to="/home/group">
                <li @click="to('group')" style="cursor: pointer">分类导航</li>
                </router-link>
              </div>

              <div >
                <li style="cursor: pointer">关于作者</li>
              </div>
              <div>
                <router-link to="/home/blogEssayInfo?id=7009c7a4-1fe0-11ea-99d2-00163e066216">
                  <li style="cursor: pointer">关于网站</li>
                </router-link>

              </div>
            </div>
          </div>
          <div class="layui-col-md4 search-box" >
            <div class="search-input-div" style="margin-right: 20px">
              <div class="layui-row">
                <div class="layui-col-md10 input-box">
                  <input class="search-input" placeholder="请输入关键字进行搜索" v-model="blogText">
                </div>
                <div class="layui-col-md2 search-btn-box">
                  <img src="/blog/imgs/icon/search.png" height="36" width="36" @click="searchBlog"/>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>
</template>

<script>
    export default {
        name: "home",
      data(){
          return {
            blogText:'',
          }
      },
        methods:{
          to(a){
           /* this.$parent.currentComponent=a;*/

          },
          searchBlog(){

            if(this.$route.path !='/home/search'){
              this.$router.push('/home/search');
            }
            let  that=this;
          this.$axios({
            method: 'get',
            url: '/blog/searchBlog?text='+this.blogText,
          })
            .then(function(res) {
              that.$store.dispatch('blog/commitSearchText',res.data.data);

            });


          },
        }
    }
</script>

<style scoped>

</style>
